window._TALKCONFIG = {

    //通关台词
    'gameEnd':[
        '恭喜通关游戏!!',
        '通关游戏后开启下一个周目',
        '重新开始游戏可以选择继承存档'        
    ],

    //开局台词
    'gameStart':[
        '开始游戏前我先讲几句,请耐心看完',
        '首先这个游戏是点击屏幕移动(PC支持WASD)',
        '本游戏主要是通过不断完成主线任务来推进游戏进程最终通关',
        '主线任务可以通过点击屏幕左边的头像查看(都是在XXX地图打赢XXX之战)',
        '在战场上使用葫芦可以招募队友,完成主线也会获得队友',
        '在酒馆消耗招募券可以直接招募队员,前提是要解锁图鉴',
        '在武器商店可以买到D级装备,更高品质的装备在野外掉落',
        '在丹药店和道具店可以买到许多很实用的道具,可以多多光顾',
        '锻造店可以强化装备,不过要注意不要强化过头无法穿戴',
        '仓库界面也可也点击一键锻造来进行武器锻造',
        '融合商店是一个强大的功能,也是本作最主要培养手段,详细功能在融合商店有说明',
        '最后再给一个忠告,不知道如果继续游戏的时候就找GM吧',
        '好的,冒险开始了！'
    ],
    //第一次战斗
    'fightStart':[
        '第一次战斗我先讲几句,请耐心看完',
        '首先这个游戏的战斗为战棋模式',
        '玩家通过操作棋盘上的单位移动,攻击,释放技能等操作击杀所有敌方单位获得战斗胜利',
        '界面上方的头像列表为行动顺序,轮到的单位可以执行一项指令',
        '行动顺序两边的头像为敌我双方的血量和行动次数',
        '普通战斗没有行动次数限制,BOSS战斗限制行动次数,超过这个次数视为战斗失败',
        '战斗单位的上有血条,技能灯,和能量条等信息',
        '敌我双方的血条颜色不同请注意区分',
        '正常情况下每个单位轮到的时候技能灯会恢复一个,技能灯足够的时候就可以释放技能',
        '能量条前方圆圈内的数字为能量值,所有单位中能量值最大的一个获得一个行动回合',
        '而角色的速度决定能量值增长的快慢,当然游戏中也有直接恢复能量值的技能',
        '轮到角色行动时,棋盘上会点亮这个角色的行动范围和攻击范围,点击蓝色的移动范围后,会出现可执行的命令',
        '点击攻击选择目标进行攻击,点击技能选择目标进行释放,点击道具选择道具进行使用,点击待机则直接跳过一个回合',
        '游戏右下方还有几个操作按钮,可以选择加速,调查,撤退和自动战斗等功能',
        '好的,那么战斗开始了！'
    ],

}

window._TALKHELPER = {

    createFightStartTalk:function(){

        var messageArr = _TALKCONFIG['fightStart'];
        var face = window.gameData.playerTeam[0].face;
        var name = window.gameData.playerTeam[0].name;
        var talkArr = [];
        for(var i=0;i<messageArr.length;i++){
            talkArr.push({
                            face:face,
                            name:name,
                            msg:messageArr[i].replace('{name}',name)}
                        );
        }

        return {
            talk:talkArr,
            talkType:'fightStart'
        };

    },


    createGameStartTalk:function(){

        var messageArr = _TALKCONFIG['gameStart'];
        var face = window.gameData.playerTeam[0].face;
        var name = window.gameData.playerTeam[0].name;
        var talkArr = [];
        for(var i=0;i<messageArr.length;i++){
            talkArr.push({
                            face:face,
                            name:name,
                            msg:messageArr[i].replace('{name}',name)}
                        );
        }

        return {
            talk:talkArr,
            talkType:'gameStart'
        };

    },

    createGameEndTalk:function(type){

        var messageArr = _TALKCONFIG['gameEnd'];
        var face = window.gameData.playerTeam[0].face;
        var name = window.gameData.playerTeam[0].name;
        var talkArr = [];
        for(var i=0;i<messageArr.length;i++){
            talkArr.push({
                            face:face,
                            name:name,
                            msg:messageArr[i].replace('{name}',name)}
                        );
        }

        return {
            talk:talkArr,
            talkType:'gameEnd',
            gameEndType:type
        };

    },

    getMessageOfNpcAndSence:function(sence,npcconf,param){
        var talkConfig = _TALKCONFIG[sence];
        var message = talkConfig["default"];
        if(npcconf.cha&&talkConfig[npcconf.cha]){
            message = talkConfig[npcconf.cha];
        }
        message = message.replace("{name}",npcconf.name);

        if(param){
            for(var key in param){
                message = message.replace("{"+key+"}",param[key]);
            }
        }
        return message;
    },

    createCommonTalkWithParam:function(npc,sence,talkType,param){
        var npcconf = _NPC[npc.t];
        var message = _TALKHELPER.getMessageOfNpcAndSence(sence,npcconf,param);
        return {
            talk:[
                {face:npcconf.face,name:npcconf.name,msg:message},
            ],
            talkType:talkType,
            talkNpc:npc.t,
            talkparam:param
        }
    },

    createCommonTalk:function(npc,sence,talkType){
        var npcconf = _NPC[npc.t];
        var message = _TALKHELPER.getMessageOfNpcAndSence(sence,npcconf,null);
        return {
            talk:[
                {face:npcconf.face,name:npcconf.name,msg:message},
            ],
            talkType:talkType,
            talkNpc:npc.t
        }
    },

    createFirstTalk:function(npc,talkType){
        var npcconf = _NPC[npc.t];
        var message = _TALKHELPER.getMessageOfNpcAndSence(talkType?talkType:'001',npcconf,null);
        return {
            talk:[
                {face:npcconf.face,name:npcconf.name,msg:message},
            ],
            talkType:'first',
            talkNpc:npc.t
        }

    },

    createNormalTalk:function(npc){
        var npcconf = _NPC[npc.t];
        var message = _TALKHELPER.getMessageOfNpcAndSence('002',npcconf,null);
        return {
            talk:[
                {face:npcconf.face,name:npcconf.name,msg:message},
            ],
            talkType:'normal',
            talkNpc:npc.t
        }

    },

    createNormalNpcTalk:function(npcconf){
        if(npcconf.type=="armyinfo"){

            var dropArr = _FIGHTPREPARE.getDropTalk(npcconf.city);
            var talkArr = [];
            for(var i=0;i<dropArr.length;i++){
                talkArr.push({face:npcconf.face,name:npcconf.name,msg:dropArr[i]});
            }

            return {
                talk:talkArr,
                talkType:'normal'
            }

        }else if(npcconf.type=="give"&&!npcconf.give){

            var levelBright = window.gameData.levelBright;
            var levelDark = window.gameData.levelDark;

            if(levelDark>=1200&&Math.random()<0.1){
                npcconf.give=1;
                return {
                    talk:[
                        {face:npcconf.face,name:npcconf.name,msg:'请帮帮我们吧,毕竟只有像您这样的大恶人才能对付ATM啊'},
                    ],
                    talkType:'giveItem',
                    item:'奇怪的书'
                }

            }else if(levelBright>=100){
                npcconf.give=1;
                return {
                    talk:[
                        {face:npcconf.face,name:npcconf.name,msg:'莫非您就是那位远近闻名的'+window.gameData.playerTeam[0].name},
                        {face:npcconf.face,name:npcconf.name,msg:'小小礼物不成敬意'},
                    ],
                    talkType:'giveItem',
                    item:_FIGHTITEMHELPER.randomItemByLevel(levelBright)
                }

            }

        }else if(npcconf.type=="juanzen"){
            return {
                talk:[
                    {face:npcconf.face,name:npcconf.name,msg:'捐赠金钱可以抵消恶名,1亿抵消1点'},
                ],
                talkType:'cutDarkLevel'
            }
        }

        return {
            talk:[
                {face:npcconf.face,name:npcconf.name,msg:npcconf.msg},
            ],
            talkType:'normal'
        }
    },

    createGameStartTalk2:function(){

        var messageArr = _TALKCONFIG['secondGameStart'];
        var face = window.gameData.playerTeam[0].face;
        var name = window.gameData.playerTeam[0].name;
        var talkArr = [];
        for(var i=0;i<messageArr.length;i++){
            talkArr.push({
                            face:face,
                            name:name,
                            msg:messageArr[i].replace('{name}',name)}
                        );
        }

        return {
            talk:talkArr,
            talkType:'gameStart2'
        };

    },

    createGameEndTalk2:function(){

        var messageArr = _TALKCONFIG['secondGameEnd'];
        var face = window.gameData.playerTeam[0].face;
        var name = window.gameData.playerTeam[0].name;
        var talkArr = [];
        for(var i=0;i<messageArr.length;i++){
            talkArr.push({
                            face:face,
                            name:name,
                            msg:messageArr[i].replace('{name}',name)}
                        );
        }

        return {
            talk:talkArr,
            talkType:'gameEnd2'
        };

    },

    createFujiTalk:function(){
        var face = window.gameData.playerTeam[0].face;
        var name = window.gameData.playerTeam[0].name;
        return {
            talk:[
                {face:"问号",name:"???",msg:name+"你恶贯满盈！今日就是你的死期！"},
                {face:face,name:name,msg:"他妈的有埋伏！"}
            ],
            talkType:'fujifight'
        };
    },

    

}